Skip to main content

๐Ÿ“ง Jenkins Email Notification and Build Triggers Guide

A simple, complete reference for configuring Jenkins triggers and email notifications โ€” explained in easy words! ๐Ÿš€


๐Ÿงฉ Parameterized Jenkins Jobsโ€‹

โœ… What is a Parameterized Job?โ€‹

A parameterized job allows users to input values when triggering a build. These inputs (parameters) are passed into the job to customize the behavior.

๐Ÿงฐ Common Parameter Typesโ€‹

TypeDescription
๐Ÿ“ StringText input (e.g., version number)
๐Ÿ”˜ BooleanCheckbox (true / false)
๐Ÿ“‹ ChoiceDropdown menu
๐Ÿ” PasswordSecure hidden input
๐Ÿ“„ Multi-line StringMulti-line text
๐Ÿ“Ž FileUpload a file
โšก Active Choice ๐Ÿ”ŒDynamic options (via plugin)
๐ŸŒฟ Git Parameter ๐Ÿ”ŒPick Git branches/tags (via plugin)

โœ๏ธ Example for Pipeline Jobsโ€‹

pipeline {
agent any
parameters {
string(name: 'VERSION', defaultValue: '1.0', description: 'Version to deploy')
booleanParam(name: 'RUN_TESTS', defaultValue: true, description: 'Run tests?')
choice(name: 'ENV', choices: ['dev', 'stage', 'prod'], description: 'Target environment')
}
stages {
stage('Deploy') {
steps {
echo "Deploying version ${params.VERSION} to ${params.ENV}"
}
}
}
}

โฐ Jenkins Build Triggers โ€“ Explained Simplyโ€‹

TriggerMeaningExample Use Case
๐ŸŒ Trigger builds remotelyRun build via URL or scriptUse curl to trigger Jenkins
๐Ÿ”— Build after other projects are builtTrigger this job after another finishesChain builds
โฒ๏ธ Build periodicallyRun on schedule (CRON)Every day at 9 AM
๐Ÿช GitHub hook triggerGitHub sends signal to buildWebhook setup
๐Ÿ”„ Poll SCMJenkins checks Git for changesEvery 5 mins check for code changes

๐Ÿ“Œ Example CRON: Build every 5 minutesโ€‹

H/5 * * * *

๐Ÿ” Jenkins Post-Build Triggers (Detailed)โ€‹

OptionDescriptionUse Case
โœ… Trigger only if build is stableRun next job only if build is successfulProduction deployment
โš ๏ธ Trigger even if build is unstableContinue even if tests failNotify, generate reports
โŒ Trigger even if the build failsRun next job on failureSend alerts, collect logs
๐Ÿ” Always trigger (even if aborted)Run regardless of resultCleanup, release locks

๐Ÿšซ "Ignore post-commit hooks" in Jenkinsโ€‹

โœ… What is a post-commit hook?โ€‹

A Git or GitHub feature that sends a signal to Jenkins after code is pushed.

โ“ What does "Ignore post-commit hooks" mean?โ€‹

It means Jenkins will ignore webhook signals and wonโ€™t build the job automatically.

๐Ÿ’ก When to useโ€‹

  • You only want Jenkins to poll Git (using Poll SCM)
  • You donโ€™t want automatic builds from webhooks

๐Ÿ“ง Jenkins Email Notification Setupโ€‹

โœ… What it doesโ€‹

Sends emails when a build fails, becomes unstable, or returns to normal.


๐Ÿ› ๏ธ Step 1: Configure Global Settingsโ€‹

Navigate to:

Manage Jenkins โ†’ Configure System โ†’ E-mail Notification

Set the following:

  • ๐Ÿ“ฎ SMTP server: smtp.gmail.com
  • ๐Ÿ”Œ SMTP port: 587
  • ๐Ÿ” Use SMTP Auth: โœ…
  • ๐Ÿ‘ค Username: [email protected]
  • ๐Ÿ”‘ Password: App Password (not your Gmail password)
  • ๐Ÿ“จ From Address: [email protected] or your Gmail
  • ๐Ÿ”’ TLS / SSL: Enable as required

โœ… Click Test Configuration

Also set the System Admin e-mail address at the top.


๐Ÿ“ฌ Step 2: Add Email Notification to Jobโ€‹

  1. Open your Jenkins job
  2. Click Configure
  3. Scroll to Post-build Actions
  4. Click Add post-build action โ†’ E-mail Notification
  5. Add recipients:

Optional checkboxes:

  • โ˜‘๏ธ Send email for every unstable build
  • โ˜‘๏ธ Send separate e-mails to individuals who broke the build

Click Save


โ“ Will Jenkins send email to [email protected]?โ€‹

โœ… Yes, if:

  • SMTP is properly configured
  • The email address is valid
  • The build fails or becomes unstable

๐Ÿ“ค From which email will Jenkins send?โ€‹

From the email set in:

Manage Jenkins โ†’ Configure System โ†’ E-mail Notification โ†’ From address

Usually:

[email protected]


๐Ÿงพ Summary: Jenkins Notifications & Triggersโ€‹

FeaturePurpose
๐ŸŽ›๏ธ Parameterized JobsLet users customize job input
๐Ÿš€ TriggersAuto-start job on events (push, schedule, scripts)
๐Ÿ” Post-build TriggersControl what happens after job finishes
๐Ÿ“ง Email NotificationSend emails on failure / unstable / stable
๐Ÿšซ Ignore post-commit hooksPrevent auto-builds from GitHub/Git

๐Ÿง  Pro Tipโ€‹

Always test email configuration using the "Test configuration by sending test e-mail" button in Jenkins settings! โœ